<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>vue实例的生命周期</title>
  <script src="./js/vue2.js"></script>
</head>
<body>
  <div id="app">{{msg}}</div>
</body>
</html>
<script>
  var app = new Vue({
    el:'#app',
    data:{
      msg: 'vue实例的生命周期'
    },
    beforeCreate () {
      console.log('--------------beforeCreate------------');
      console.log(this.$el);
      console.log(this.msg);
    },
    created () {
      console.log('--------------created------------');
      console.log(this.$el);
      console.log(this.msg);//有数据
    },
    beforeMount () {
      console.log('--------------beforeMount------------');
      console.log(this.$el);// 有数据，但是未绑定 msg
      console.log(this.msg);//有数据
    },
    mounted () {
      console.log('--------------mounted------------');
      console.log(this.$el);// 有数据，已绑定 msg
      console.log(this.msg);//有数据
    },
    beforeUpdate () {
      console.log('--------------beforeUpdate------------');
    },
    updated () {
      console.log('--------------updated------------');
    },
    beforeDestroy () {
      console.log('--------------beforeDestroy------------');
    },
    destroyed () {
      console.log('--------------destroyed------------');
    }
  });
</script>